package com.e.library.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import java.util.List;

/**
 * Recycler单布局adapter
 * 多种布局{@link AdapterX}
 * Created by lxy on 2016/7/5.
 */
public abstract class Adapter<Data> extends EAdapter<Data> {

    protected abstract int layout();
    protected abstract void bind(EHolder holder, Data data, int position);

    public Adapter(Context context, List<Data> datas) {
        super(context, datas);
    }

    @Override
    public EHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new EHolder(LayoutInflater.from(mContext).inflate(layout(),parent,false));
    }

    @Override
    public void onBindViewHolder(EHolder holder, int position) {
        Data data = mDatas.get(position);
        bind(holder,data,position);
        onBindItemClickListener(holder.itemView,data,position);
    }
}
